Implement --color [auto|always|never].
authorMike Boutin <mike.boutin@gmail.com>
Fri, 17 Jul 2015 23:41:56 +0000 (19:41 -0400)
committerMike Boutin <mike.boutin@gmail.com>
Tue, 4 Aug 2015 23:03:00 +0000 (19:03 -0400)
Closes #1363.

30 files changed:
src/bin/bench.rs
src/bin/build.rs
src/bin/cargo.rs
src/bin/clean.rs
src/bin/doc.rs
src/bin/fetch.rs
src/bin/generate_lockfile.rs
src/bin/git_checkout.rs
src/bin/login.rs
src/bin/new.rs
src/bin/owner.rs
src/bin/package.rs
src/bin/pkgid.rs
src/bin/publish.rs
src/bin/read_manifest.rs
src/bin/run.rs
src/bin/rustc.rs
src/bin/search.rs
src/bin/test.rs
src/bin/update.rs
src/bin/verify_project.rs
src/bin/version.rs
src/bin/yank.rs
src/cargo/core/mod.rs
src/cargo/core/shell.rs
src/cargo/lib.rs
src/etc/_cargo
src/etc/cargo.1
src/etc/cargo.bashcomp.sh
tests/test_shell.rs

index 4b9d5164aef1b18b0574a3997ef387f5522a03cd..a1aabb89f65ece0ea0e641b323a89b5e3584f749 100644 (file)
@@ -13,6 +13,7 @@ struct Options {
     flag_manifest_path: Option<String>,
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
     flag_lib: bool,
     flag_bin: Vec<String>,
     flag_example: Vec<String>,
@@ -43,6 +44,7 @@ Options:
     --manifest-path PATH     Path to the manifest to build benchmarks for
     -v, --verbose            Use verbose output
     -q, --quiet              No output printed to stdout
+    --color WHEN             Coloring: auto, always, never
 
 All of the trailing arguments are passed to the benchmark binaries generated
 for filtering benchmarks and generally providing options configuring how they
@@ -62,6 +64,7 @@ Compilation can be customized with the `bench` profile in the manifest.
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
 
     let ops = ops::TestOptions {
         no_run: options.flag_no_run,
index 0ba089e1bb211cae24c27e9708610c0c6bf4e6bd..577baa49067754bb8268f0769cdfd3cd505d293e 100644 (file)
@@ -15,6 +15,7 @@ struct Options {
     flag_manifest_path: Option<String>,
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
     flag_release: bool,
     flag_lib: bool,
     flag_bin: Vec<String>,
@@ -45,6 +46,7 @@ Options:
     --manifest-path PATH     Path to the manifest to compile
     -v, --verbose            Use verbose output
     -q, --quiet              No output printed to stdout
+    --color WHEN             Coloring: auto, always, never
 
 If the --package argument is given, then SPEC is a package id specification
 which indicates which package should be built. If it is not given, then the
@@ -60,6 +62,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     debug!("executing; cmd=cargo-build; args={:?}",
            env::args().collect::<Vec<_>>());
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
 
     let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
 
index 73646756d3171195059cb80cfb6945bcbb5d6f1e..bfa763852e021c3456e26a804f766cd75035011e 100644 (file)
@@ -21,6 +21,7 @@ struct Flags {
     flag_list: bool,
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
     arg_command: String,
     arg_args: Vec<String>,
 }
@@ -33,11 +34,12 @@ Usage:
     cargo [options]
 
 Options:
-    -h, --help       Display this message
-    -V, --version    Print version info and exit
-    --list           List installed commands
-    -v, --verbose    Use verbose output
-    -q, --quiet             No output printed to stdout
+    -h, --help          Display this message
+    -V, --version       Print version info and exit
+    --list              List installed commands
+    -v, --verbose       Use verbose output
+    -q, --quiet         No output printed to stdout
+    --color WHEN        Coloring: auto, always, never
 
 Some common cargo commands are:
     build       Compile the current project
@@ -92,6 +94,7 @@ macro_rules! each_subcommand{ ($mac:ident) => ({
 */
 fn execute(flags: Flags, config: &Config) -> CliResult<Option<()>> {
     try!(config.shell().set_verbosity(flags.flag_verbose, flags.flag_quiet));
+    try!(config.shell().set_color_config(flags.flag_color.as_ref().map(|s| &s[..])));
 
     init_git_transports(config);
 
index 825d05c713d4da6103a03a8613ddd8eddbd1d21e..18c6111e56e7014394e875337a76081e2aab8178 100644 (file)
@@ -11,6 +11,7 @@ struct Options {
     flag_manifest_path: Option<String>,
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
 }
 
 pub const USAGE: &'static str = "
@@ -26,6 +27,7 @@ Options:
     --target TRIPLE          Target triple to clean output for (default all)
     -v, --verbose            Use verbose output
     -q, --quiet              No output printed to stdout
+    --color WHEN             Coloring: auto, always, never
 
 If the --package argument is given, then SPEC is a package id specification
 which indicates which package's artifacts should be cleaned out. If it is not
@@ -35,6 +37,7 @@ and its format, see the `cargo help pkgid` command.
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
     debug!("executing; cmd=cargo-clean; args={:?}", env::args().collect::<Vec<_>>());
 
     let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
index 157f3f3930764fb3952df849792e2d2a692fd34e..6bc43a86b04ef326863b102a6110a2a0ef3db87e 100644 (file)
@@ -13,6 +13,7 @@ struct Options {
     flag_open: bool,
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
     flag_package: Option<String>,
 }
 
@@ -34,6 +35,7 @@ Options:
     --manifest-path PATH     Path to the manifest to document
     -v, --verbose            Use verbose output
     -q, --quiet              No output printed to stdout
+    --color WHEN             Coloring: auto, always, never
 
 By default the documentation for the local package and all dependencies is
 built. The output is all placed in `target/doc` in rustdoc's usual format.
@@ -46,6 +48,7 @@ the `cargo help pkgid` command.
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
 
     let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
 
index 3c8ecbdc476725513a2869441a747ffe1c048c67..94087f026c3d73137741448ace343c4bcc889800 100644 (file)
@@ -7,6 +7,7 @@ struct Options {
     flag_manifest_path: Option<String>,
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
 }
 
 pub const USAGE: &'static str = "
@@ -16,10 +17,11 @@ Usage:
     cargo fetch [options]
 
 Options:
-    -h, --help              Print this message
-    --manifest-path PATH    Path to the manifest to fetch dependencies for
-    -v, --verbose           Use verbose output
-    -q, --quiet             No output printed to stdout
+    -h, --help               Print this message
+    --manifest-path PATH     Path to the manifest to fetch dependencies for
+    -v, --verbose            Use verbose output
+    -q, --quiet              No output printed to stdout
+    --color WHEN             Coloring: auto, always, never
 
 If a lockfile is available, this command will ensure that all of the git
 dependencies and/or registries dependencies are downloaded and locally
@@ -33,6 +35,7 @@ all updated.
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
     let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
     try!(ops::fetch(&root, config).map_err(|e| {
         CliError::from_boxed(e, 101)
index bb2ade5fef9108dfa1a88e541ee2fa4bf98dd2e5..29891f1c846f84e7419089dfc6f92aec10447571 100644 (file)
@@ -9,6 +9,7 @@ struct Options {
     flag_manifest_path: Option<String>,
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
 }
 
 pub const USAGE: &'static str = "
@@ -18,15 +19,17 @@ Usage:
     cargo generate-lockfile [options]
 
 Options:
-    -h, --help              Print this message
-    --manifest-path PATH    Path to the manifest to generate a lockfile for
-    -v, --verbose           Use verbose output
-    -q, --quiet             No output printed to stdout
+    -h, --help               Print this message
+    --manifest-path PATH     Path to the manifest to generate a lockfile for
+    -v, --verbose            Use verbose output
+    -q, --quiet              No output printed to stdout
+    --color WHEN             Coloring: auto, always, never
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     debug!("executing; cmd=cargo-generate-lockfile; args={:?}", env::args().collect::<Vec<_>>());
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
     let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
 
     ops::generate_lockfile(&root, config)
index eaf1df3671d4244940c1c410acc7d988f56097ab..ff4d5f4c46cbb27a74cdfa3bc97c7397415870c5 100644 (file)
@@ -8,6 +8,7 @@ struct Options {
     flag_reference: String,
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
 }
 
 pub const USAGE: &'static str = "
@@ -16,13 +17,15 @@ Usage:
     cargo git-checkout -h | --help
 
 Options:
-    -h, --help              Print this message
-    -v, --verbose           Use verbose output
-    -q, --quiet             No output printed to stdout
+    -h, --help               Print this message
+    -v, --verbose            Use verbose output
+    -q, --quiet              No output printed to stdout
+    --color WHEN             Coloring: auto, always, never
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
     let Options { flag_url: url, flag_reference: reference, .. } = options;
 
     let url = try!(url.to_url().map_err(|e| {
index a0ec4bfea83a6274880fc819d8ccf8513c9f6b3d..bfcc2f8ae3d00f67da6f378ce95d64ee86ecf1a8 100644 (file)
@@ -12,6 +12,7 @@ struct Options {
     arg_token: Option<String>,
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
 }
 
 pub const USAGE: &'static str = "
@@ -21,15 +22,17 @@ Usage:
     cargo login [options] [<token>]
 
 Options:
-    -h, --help              Print this message
-    --host HOST             Host to set the token for
-    -v, --verbose           Use verbose output
-    -q, --quiet             No output printed to stdout
+    -h, --help               Print this message
+    --host HOST              Host to set the token for
+    -v, --verbose            Use verbose output
+    -q, --quiet              No output printed to stdout
+    --color WHEN             Coloring: auto, always, never
 
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
     let token = match options.arg_token.clone() {
         Some(token) => token,
         None => {
index 6c1b6598cef1210ab607c0b1d1afad5cd2ba3990..0c6864448e81c9decd585c1eaa38459827a65272 100644 (file)
@@ -7,6 +7,7 @@ use cargo::util::{CliResult, CliError, Config};
 struct Options {
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
     flag_bin: bool,
     arg_path: String,
     flag_name: Option<String>,
@@ -29,11 +30,13 @@ Options:
     --name <name>       Set the resulting package name
     -v, --verbose       Use verbose output
     -q, --quiet         No output printed to stdout
+    --color WHEN        Coloring: auto, always, never
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     debug!("executing; cmd=cargo-new; args={:?}", env::args().collect::<Vec<_>>());
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
 
     let Options { flag_bin, arg_path, flag_name, flag_vcs, .. } = options;
 
index 598555a9a5b6905461408e242d59edb822af0442..cf2ca2ec63dd1e53852f9bba6d5fdeac41d1cae6 100644 (file)
@@ -10,6 +10,7 @@ struct Options {
     flag_index: Option<String>,
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
     flag_list: bool,
 }
 
@@ -20,14 +21,15 @@ Usage:
     cargo owner [options] [<crate>]
 
 Options:
-    -h, --help              Print this message
-    -a, --add LOGIN         Login of a user to add as an owner
-    -r, --remove LOGIN      Login of a user to remove as an owner
-    -l, --list              List owners of a crate
-    --index INDEX           Registry index to modify owners for
-    --token TOKEN           API token to use when authenticating
-    -v, --verbose           Use verbose output
-    -q, --quiet             No output printed to stdout
+    -h, --help               Print this message
+    -a, --add LOGIN          Login of a user to add as an owner
+    -r, --remove LOGIN       Login of a user to remove as an owner
+    -l, --list               List owners of a crate
+    --index INDEX            Registry index to modify owners for
+    --token TOKEN            API token to use when authenticating
+    -v, --verbose            Use verbose output
+    -q, --quiet              No output printed to stdout
+    --color WHEN             Coloring: auto, always, never
 
 This command will modify the owners for a package on the specified registry (or
 default). Note that owners of a package can upload new versions, yank old
@@ -36,6 +38,7 @@ versions, and also modify the set of owners, so take caution!
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
     let opts = ops::OwnersOptions {
         krate: options.arg_crate,
         token: options.flag_token,
index 828fac3cce2ac4753492fa03779ea34d30e68e96..4d3b72b716ad7ca129601151e7b59e47b06735ce 100644 (file)
@@ -6,6 +6,7 @@ use cargo::util::important_paths::find_root_manifest_for_cwd;
 struct Options {
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
     flag_manifest_path: Option<String>,
     flag_no_verify: bool,
     flag_no_metadata: bool,
@@ -26,11 +27,13 @@ Options:
     --manifest-path PATH    Path to the manifest to compile
     -v, --verbose           Use verbose output
     -q, --quiet             No output printed to stdout
+    --color WHEN            Coloring: auto, always, never
 
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
     let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
     ops::package(&root, config,
                  !options.flag_no_verify,
index 400719e77ec731b8fd058d9e43dfc93d369afec6..abbe4e52fc7e1b9d83cf871da00b70f7f3317c91 100644 (file)
@@ -6,6 +6,7 @@ use cargo::util::important_paths::{find_root_manifest_for_cwd};
 struct Options {
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
     flag_manifest_path: Option<String>,
     arg_spec: Option<String>,
 }
@@ -17,10 +18,11 @@ Usage:
     cargo pkgid [options] [<spec>]
 
 Options:
-    -h, --help              Print this message
-    --manifest-path PATH    Path to the manifest to the package to clean
-    -v, --verbose           Use verbose output
-    -q, --quiet             No output printed to stdout
+    -h, --help               Print this message
+    --manifest-path PATH     Path to the manifest to the package to clean
+    -v, --verbose            Use verbose output
+    -q, --quiet              No output printed to stdout
+    --color WHEN             Coloring: auto, always, never
 
 Given a <spec> argument, print out the fully qualified package id specifier.
 This command will generate an error if <spec> is ambiguous as to which package
@@ -46,6 +48,7 @@ Example Package IDs
 pub fn execute(options: Options,
                config: &Config) -> CliResult<Option<()>> {
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
     let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path.clone()));
 
     let spec = options.arg_spec.as_ref().map(|s| &s[..]);
index 478947b441b9128f45dcc3cc5c845379593567ce..387daecd2353fc921fa6cb0dedfe779351094eed 100644 (file)
@@ -9,6 +9,7 @@ struct Options {
     flag_manifest_path: Option<String>,
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
     flag_no_verify: bool,
 }
 
@@ -19,18 +20,20 @@ Usage:
     cargo publish [options]
 
 Options:
-    -h, --help              Print this message
-    --host HOST             Host to upload the package to
-    --token TOKEN           Token to use when uploading
-    --no-verify             Don't verify package tarball before publish
-    --manifest-path PATH    Path to the manifest to compile
-    -v, --verbose           Use verbose output
-    -q, --quiet             No output printed to stdout
+    -h, --help               Print this message
+    --host HOST              Host to upload the package to
+    --token TOKEN            Token to use when uploading
+    --no-verify              Don't verify package tarball before publish
+    --manifest-path PATH     Path to the manifest to compile
+    -v, --verbose            Use verbose output
+    -q, --quiet              No output printed to stdout
+    --color WHEN             Coloring: auto, always, never
 
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
     let Options {
         flag_token: token,
         flag_host: host,
index bd8f9e36658dd1906fa4d85e1187eae4c87de840..591d9f42ff0ca4eec066ef784fadb635e50ce13f 100644 (file)
@@ -8,6 +8,7 @@ use cargo::sources::{PathSource};
 #[derive(RustcDecodable)]
 struct Options {
     flag_manifest_path: String,
+    flag_color: Option<String>,
 }
 
 pub const USAGE: &'static str = "
@@ -16,11 +17,13 @@ Usage:
     cargo read-manifest -h | --help
 
 Options:
-    -h, --help              Print this message
-    -v, --verbose           Use verbose output
+    -h, --help               Print this message
+    -v, --verbose            Use verbose output
+    --color WHEN             Coloring: auto, always, never
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<Package>> {
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
     let path = Path::new(&options.flag_manifest_path);
     let mut source = try!(PathSource::for_path(&path, config).map_err(|e| {
         CliError::new(e.description(), 1)
index 71718ef1d07d25026b566ff143b39a29238dd538..7d411056a20e3a0019eae85d86b8c332747b83c0 100644 (file)
@@ -13,6 +13,7 @@ struct Options {
     flag_manifest_path: Option<String>,
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
     flag_release: bool,
     arg_args: Vec<String>,
 }
@@ -35,6 +36,7 @@ Options:
     --manifest-path PATH    Path to the manifest to execute
     -v, --verbose           Use verbose output
     -q, --quiet             No output printed to stdout
+    --color WHEN            Coloring: auto, always, never
 
 If neither `--bin` nor `--example` are given, then if the project only has one
 bin target it will be run. Otherwise `--bin` specifies the bin target to run,
@@ -46,6 +48,7 @@ All of the trailing arguments are passed to the binary to run.
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
 
     let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
 
index 0292d79e711a5b50a7109571d374073076a3dd95..920096c2bf6750b41fe435d6c7832305852b5014 100644 (file)
@@ -16,6 +16,7 @@ struct Options {
     flag_manifest_path: Option<String>,
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
     flag_release: bool,
     flag_lib: bool,
     flag_bin: Vec<String>,
@@ -46,6 +47,7 @@ Options:
     --manifest-path PATH     Path to the manifest to fetch dependencies for
     -v, --verbose            Use verbose output
     -q, --quiet              No output printed to stdout
+    --color WHEN             Coloring: auto, always, never
 
 The specified target for the current package (or package specified by SPEC if
 provided) will be compiled along with all of its dependencies. The specified
@@ -63,6 +65,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     debug!("executing; cmd=cargo-rustc; args={:?}",
            env::args().collect::<Vec<_>>());
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
 
     let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
 
index 8710f546da45c13a864261e2c03631e953d22e25..05c5475855d31cb64b9fcb5c79a845faed602c65 100644 (file)
@@ -6,6 +6,7 @@ struct Options {
     flag_host: Option<String>,
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
     arg_query: String
 }
 
@@ -17,14 +18,16 @@ Usage:
     cargo search [-h | --help]
 
 Options:
-    -h, --help              Print this message
-    --host HOST             Host of a registry to search in
-    -v, --verbose           Use verbose output
-    -q, --quiet             No output printed to stdout
+    -h, --help               Print this message
+    --host HOST              Host of a registry to search in
+    -v, --verbose            Use verbose output
+    -q, --quiet              No output printed to stdout
+    --color WHEN             Coloring: auto, always, never
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
     let Options {
         flag_host: host,
         arg_query: query,
index aafa8ec1cb22f8c4e70cfdcd8bc8047687b30833..44b6c60c8968fbfa01c2185ac811b67dad942ca2 100644 (file)
@@ -19,6 +19,7 @@ struct Options {
     flag_bench: Vec<String>,
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
     flag_release: bool,
 }
 
@@ -45,6 +46,7 @@ Options:
     --manifest-path PATH     Path to the manifest to build tests for
     -v, --verbose            Use verbose output
     -q, --quiet              No output printed to stdout
+    --color WHEN             Coloring: auto, always, never
 
 All of the trailing arguments are passed to the test binaries generated for
 filtering tests and generally providing options configuring how they run. For
@@ -66,6 +68,7 @@ Compilation can be configured via the `test` profile in the manifest.
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
 
     let ops = ops::TestOptions {
         no_run: options.flag_no_run,
index f1956566bf1c95e32cbaac124c276c0d894f7ee2..cd4cd1173aae52d193059d32aba78584a0908dd0 100644 (file)
@@ -12,6 +12,7 @@ struct Options {
     flag_manifest_path: Option<String>,
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
 }
 
 pub const USAGE: &'static str = "
@@ -28,6 +29,7 @@ Options:
     --manifest-path PATH     Path to the manifest to compile
     -v, --verbose            Use verbose output
     -q, --quiet              No output printed to stdout
+    --color WHEN             Coloring: auto, always, never
 
 This command requires that a `Cargo.lock` already exists as generated by
 `cargo build` or related commands.
@@ -53,6 +55,7 @@ For more information about package id specifications, see `cargo help pkgid`.
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     debug!("executing; cmd=cargo-update; args={:?}", env::args().collect::<Vec<_>>());
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
     let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
 
     let spec = options.flag_package.as_ref();
index 5b72f06678e5b6d97add80cb39973a95d4e8ea6c..b8d3f657c338ef8294fb59de1830bc49620e987e 100644 (file)
@@ -14,6 +14,7 @@ struct Flags {
     flag_manifest_path: String,
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
 }
 
 pub const USAGE: &'static str = "
@@ -26,10 +27,12 @@ Options:
     --manifest-path PATH    Path to the manifest to verify
     -v, --verbose           Use verbose output
     -q, --quiet             No output printed to stdout
+    --color WHEN            Coloring: auto, always, never
 ";
 
 pub fn execute(args: Flags, config: &Config) -> CliResult<Option<Error>> {
     try!(config.shell().set_verbosity(args.flag_verbose, args.flag_quiet));
+    try!(config.shell().set_color_config(args.flag_color.as_ref().map(|s| &s[..])));
 
     let mut contents = String::new();
     let file = File::open(&args.flag_manifest_path);
index b5622f225c906681dad51ff12db626eced1b8d7e..12c954f58c48eafb9163818cf5c31966be704541 100644 (file)
@@ -11,8 +11,9 @@ Usage:
     cargo version [options]
 
 Options:
-    -h, --help              Print this message
-    -v, --verbose           Use verbose output
+    -h, --help               Print this message
+    -v, --verbose            Use verbose output
+    --color WHEN             Coloring: auto, always, never
 ";
 
 pub fn execute(_: Options, _: &Config) -> CliResult<Option<()>> {
index efd2032618e2b7852520d0a55252c1f62fb22328..d5322eb55a57623c6f9230e9d673ec8e3650183d 100644 (file)
@@ -9,6 +9,7 @@ struct Options {
     flag_index: Option<String>,
     flag_verbose: bool,
     flag_quiet: bool,
+    flag_color: Option<String>,
     flag_undo: bool,
 }
 
@@ -19,13 +20,14 @@ Usage:
     cargo yank [options] [<crate>]
 
 Options:
-    -h, --help              Print this message
-    --vers VERSION          The version to yank or un-yank
-    --undo                  Undo a yank, putting a version back into the index
-    --index INDEX           Registry index to yank from
-    --token TOKEN           API token to use when authenticating
-    -v, --verbose           Use verbose output
-    -q, --quiet             No output printed to stdout
+    -h, --help          Print this message
+    --vers VERSION      The version to yank or un-yank
+    --undo              Undo a yank, putting a version back into the index
+    --index INDEX       Registry index to yank from
+    --token TOKEN       API token to use when authenticating
+    -v, --verbose       Use verbose output
+    -q, --quiet         No output printed to stdout
+    --color WHEN        Coloring: auto, always, never
 
 The yank command removes a previously pushed crate's version from the server's
 index. This command does not delete any data, and the crate will still be
@@ -38,6 +40,7 @@ crates to be locked to any yanked version.
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
     try!(ops::yank(config,
                    options.arg_crate,
                    options.flag_vers,
index f468f8c79c7499a1ee08f6731ef2772ab8e6c8a9..54c73334809fa827033cbdd29806b6dd55fdb2a2 100644 (file)
@@ -5,7 +5,7 @@ pub use self::package_id::{PackageId, Metadata};
 pub use self::package_id_spec::PackageIdSpec;
 pub use self::registry::Registry;
 pub use self::resolver::Resolve;
-pub use self::shell::{Shell, MultiShell, ShellConfig, Verbosity};
+pub use self::shell::{Shell, MultiShell, ShellConfig, Verbosity, ColorConfig};
 pub use self::source::{Source, SourceId, SourceMap, SourceSet, GitReference};
 pub use self::summary::Summary;
 
index ff5edba1045cc23fe34278887bb084525d8fedc9..227261c8c30e92e70a99a6f13568600c68af5f05 100644 (file)
@@ -8,6 +8,7 @@ use term::{Terminal, TerminfoTerminal, color};
 
 use self::AdequateTerminal::{NoColor, Colored};
 use self::Verbosity::{Verbose, Normal, Quiet};
+use self::ColorConfig::{Auto, Always, Never};
 
 use util::errors::{human, CargoResult};
 
@@ -18,10 +19,16 @@ pub enum Verbosity {
     Quiet
 }
 
+#[derive(Clone, Copy, PartialEq)]
+pub enum ColorConfig {
+    Auto,
+    Always,
+    Never
+}
+
 #[derive(Clone, Copy)]
 pub struct ShellConfig {
-    pub color: bool,
-    pub verbosity: Verbosity,
+    pub color_config: ColorConfig,
     pub tty: bool
 }
 
@@ -115,6 +122,21 @@ impl MultiShell {
         }
     }
 
+    pub fn set_color_config(&mut self, color: Option<&str>) -> CargoResult<()> {
+        self.out.set_color_config(match color {
+            Some("auto") => Auto,
+            Some("always") => Always,
+            Some("never") => Never,
+
+            None => Auto,
+
+            Some(arg) => return Err(human(format!("argument for --color must be auto, always, or \
+                                                   never, but found `{}`",
+                                                  arg))),
+        });
+        Ok(())
+    }
+
     pub fn get_verbose(&self) -> Verbosity {
         self.verbosity
     }
@@ -122,7 +144,9 @@ impl MultiShell {
 
 impl Shell {
     pub fn create(out: Box<Write + Send>, config: ShellConfig) -> Shell {
-        if config.tty && config.color {
+        // Check for cfg!(windows) as colored output on Windows can only be supported when a tty is
+        // present.
+        if !cfg!(windows) || config.tty {
             let term = TerminfoTerminal::new(out);
             term.map(|t| Shell {
                 terminal: Colored(Box::new(t)),
@@ -135,36 +159,17 @@ impl Shell {
         }
     }
 
-    pub fn verbose<F>(&mut self, mut callback: F) -> io::Result<()>
-        where F: FnMut(&mut Shell) -> io::Result<()>
-    {
-        match self.config.verbosity {
-            Verbose => return callback(self),
-            _ => Ok(())
-        }
-    }
-
-    pub fn concise<F>(&mut self, mut callback: F) -> io::Result<()>
-        where F: FnMut(&mut Shell) -> io::Result<()>
-    {
-        match self.config.verbosity {
-            Verbose => Ok(()),
-            _ => return callback(self)
-        }
+    pub fn set_color_config(&mut self, color_config: ColorConfig) {
+        self.config.color_config = color_config;
     }
 
     pub fn say<T: ToString>(&mut self, message: T, color: Color) -> io::Result<()> {
-        match self.config.verbosity {
-            Quiet => Ok(()),
-            _ => {
-                try!(self.reset());
-                if color != BLACK { try!(self.fg(color)); }
-                try!(write!(self, "{}\n", message.to_string()));
-                try!(self.reset());
-                try!(self.flush());
-                Ok(())
-            },
-        }
+        try!(self.reset());
+        if color != BLACK { try!(self.fg(color)); }
+        try!(write!(self, "{}\n", message.to_string()));
+        try!(self.reset());
+        try!(self.flush());
+        Ok(())
     }
 
     pub fn say_status<T, U>(&mut self, status: T, message: U, color: Color)
@@ -182,32 +187,45 @@ impl Shell {
     }
 
     fn fg(&mut self, color: color::Color) -> io::Result<bool> {
+        let colored = self.colored();
+
         match self.terminal {
-            Colored(ref mut c) => c.fg(color),
-            NoColor(_) => Ok(false)
+            Colored(ref mut c) if colored => c.fg(color),
+            _ => Ok(false)
         }
     }
 
     fn attr(&mut self, attr: Attr) -> io::Result<bool> {
+        let colored = self.colored();
+
         match self.terminal {
-            Colored(ref mut c) => c.attr(attr),
-            NoColor(_) => Ok(false)
+            Colored(ref mut c) if colored => c.attr(attr),
+            _ => Ok(false)
         }
     }
 
     fn supports_attr(&self, attr: Attr) -> bool {
+        let colored = self.colored();
+
         match self.terminal {
-            Colored(ref c) => c.supports_attr(attr),
-            NoColor(_) => false
+            Colored(ref c) if colored => c.supports_attr(attr),
+            _ => false
         }
     }
 
     fn reset(&mut self) -> io::Result<()> {
+        let colored = self.colored();
+
         match self.terminal {
-            Colored(ref mut c) => c.reset().map(|_| ()),
-            NoColor(_) => Ok(())
+            Colored(ref mut c) if colored => c.reset().map(|_| ()),
+            _ => Ok(())
         }
     }
+
+    fn colored(&self) -> bool {
+        self.config.tty && Auto == self.config.color_config
+            || Always == self.config.color_config
+    }
 }
 
 impl Write for Shell {
index 1accb5e2c1bd3f578c6eb4e5522c1600565e4032..669c5d5bf27fe7781bfdeffcde4bf3e41eb86dc6 100644 (file)
@@ -31,8 +31,9 @@ use rustc_serialize::{Decodable, Encodable};
 use rustc_serialize::json::{self, Json};
 use docopt::Docopt;
 
-use core::{Shell, MultiShell, ShellConfig, Verbosity};
+use core::{Shell, MultiShell, ShellConfig, Verbosity, ColorConfig};
 use core::shell::Verbosity::{Verbose};
+use core::shell::ColorConfig::{Auto};
 use term::color::{BLACK, RED};
 
 pub use util::{CargoError, CliError, CliResult, human, Config, ChainError};
@@ -96,7 +97,7 @@ fn process<V, F>(mut callback: F)
 {
     let mut config = None;
     let result = (|| {
-        config = Some(try!(Config::new(shell(Verbose))));
+        config = Some(try!(Config::new(shell(Verbose, Auto))));
         let args: Vec<_> = try!(env::args_os().map(|s| {
             s.into_string().map_err(|s| {
                 human(format!("invalid unicode in argument: {:?}", s))
@@ -104,7 +105,7 @@ fn process<V, F>(mut callback: F)
         }).collect());
         callback(&args, config.as_ref().unwrap())
     })();
-    let mut verbose_shell = shell(Verbose);
+    let mut verbose_shell = shell(Verbose, Auto);
     let mut shell = config.as_ref().map(|s| s.shell());
     let shell = shell.as_mut().map(|s| &mut **s).unwrap_or(&mut verbose_shell);
     process_executed(result, shell)
@@ -123,17 +124,17 @@ pub fn process_executed<T>(result: CliResult<Option<T>>, shell: &mut MultiShell)
     }
 }
 
-pub fn shell(verbosity: Verbosity) -> MultiShell {
+pub fn shell(verbosity: Verbosity, color_config: ColorConfig) -> MultiShell {
     let tty = isatty(libc::STDERR_FILENO);
     let stderr = Box::new(io::stderr());
 
-    let config = ShellConfig { color: true, verbosity: verbosity, tty: tty };
+    let config = ShellConfig { color_config: color_config, tty: tty };
     let err = Shell::create(stderr, config);
 
     let tty = isatty(libc::STDOUT_FILENO);
     let stdout = Box::new(io::stdout());
 
-    let config = ShellConfig { color: true, verbosity: verbosity, tty: tty };
+    let config = ShellConfig { color_config: color_config, tty: tty };
     let out = Shell::create(stdout, config);
 
     return MultiShell::new(out, err, verbosity);
@@ -173,7 +174,6 @@ pub fn handle_error(err: CliError, shell: &mut MultiShell) {
     let CliError { error, exit_code, unknown } = err;
     let fatal = exit_code != 0; // exit_code == 0 is non-fatal error
 
-
     let hide = unknown && shell.get_verbose() != Verbose;
     if hide {
         let _ = shell.err().say("An unknown error occurred", RED);
index d85e5a785588a998d37ef22fa16e35563ccf460d..a1c43aff8c0048c249881538c981f3379ea96ab9 100644 (file)
@@ -9,6 +9,7 @@ _arguments \
     '(- 1 *)'{-h,--help}'[show help message]' \
     '(- 1 *)'--list'[list installed commands]' \
     '(- 1 *)'{-v,--verbose}'[use verbose output]' \
+    '(- 1 *)'--color'[colorization option]' \
     '(- 1 *)'{-V,--version}'[show version information]' \
     '1: :_cargo_cmds' \
     '*:: :->args'
@@ -29,6 +30,7 @@ case $state in
                     '(-p,--package)'{-p=,--package=}'[package to run benchmarks for]:packages:_get_package_names' \
                     '--target=[target triple]' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     ;;
 
             build)
@@ -42,6 +44,7 @@ case $state in
                     '--release=[build in release mode]' \
                     '--target=[target triple]' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     ;;
 
             clean)
@@ -51,6 +54,7 @@ case $state in
                     '(-p,--package)'{-p=,--package=}'[package to clean]:packages:_get_package_names' \
                     '--target=[target triple(default:all)]' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     ;;
 
             config-for-key)
@@ -76,6 +80,7 @@ case $state in
                     '--no-default-features[do not build the default features]' \
                     '--open[oen docs in browser after the build]' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     ;;
 
             fetch)
@@ -83,6 +88,7 @@ case $state in
                     '(-h, --help)'{-h,--help}'[show help message]' \
                     '--manifest-path=[path to manifest]' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     ;;
 
             generate-lockfile)
@@ -90,6 +96,7 @@ case $state in
                     '(-h, --help)'{-h,--help}'[show help message]' \
                     '--manifest-path=[path to manifest]' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     ;;
 
             git-checkout)
@@ -98,6 +105,7 @@ case $state in
                     '--reference=[REF]' \
                     '--url=[URL]' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     ;;
 
             help)
@@ -117,6 +125,7 @@ case $state in
                     '(-h, --help)'{-h,--help}'[show help message]' \
                     '--host=[Host to set the token for]' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     ;;
 
             new)
@@ -127,6 +136,7 @@ case $state in
                     '--hg[initialize new mercurial repo]' \
                     '--no-git[no new git repo]' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     ;;
 
             owner)
@@ -137,6 +147,7 @@ case $state in
                     '(-r, --remove)'{-r,--remove}'[remove owner LOGIN]' \
                     '--token[API token]' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     ;;
 
             package)
@@ -145,6 +156,7 @@ case $state in
                     '--manifest-path=[path to manifest]' \
                     '--no-verify[do not build to verify contents]' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     ;;
 
             pkgid)
@@ -152,6 +164,7 @@ case $state in
                     '(-h, --help)'{-h,--help}'[show help message]' \
                     '--manifest-path=[path to manifest]' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     ;;
 
             publish)
@@ -162,6 +175,7 @@ case $state in
                     '--no-verify[Do not verify tarball until before publish]' \
                     '--token[Token to use when uploading]' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     ;;
 
             read-manifest)
@@ -169,6 +183,7 @@ case $state in
                     '(-h, --help)'{-h,--help}'[show help message]' \
                     '--manifest-path=[path to manifest]' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     ;;
 
             run)
@@ -183,6 +198,7 @@ case $state in
                     '--release=[build in release mode]' \
                     '--target=[target triple]' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     '*: :_normal' \
                 ;;
 
@@ -198,6 +214,7 @@ case $state in
                     '(-p,--package)'{-p=,--package=}'[package to run tests for]:packages:_get_package_names' \
                     '--target=[target triple]' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     '1: :_test_names' \
                     ;;
 
@@ -209,6 +226,7 @@ case $state in
                     '(-p,--package)'{-p=,--package=}'[package to update]:packages:__get_package_names' \
                     '--precise=[update single dependency to PRECISE]: :' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     ;;
 
             verify-project)
@@ -216,12 +234,14 @@ case $state in
                     '(-h, --help)'{-h,--help}'[show help message]' \
                     '--manifest-path=[path to manifest]' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     ;;
 
             version)
                 _arguments \
                     '(-h, --help)'{-h,--help}'[show help message]' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     ;;
 
             yank)
@@ -231,6 +251,7 @@ case $state in
                     '--token[API token]' \
                     '--undo[undo yank]' \
                     '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
+                    '--color=[colorization option]' \
                     '--vers[yank version]' \
                     ;;
         esac
index 4d41efd9eccd56ac9084992fbaef5604c1a826db..25aade5f48cefa8218a2c2215879ddee52990167 100644 (file)
@@ -26,6 +26,9 @@ List all available cargo commands
 .TP
 \fB\-v, \-\-verbose\fR
 Use verbose output
+.TP
+\fB\-\-color\fR
+Configure coloring of output
 
 .SH COMMANDS
 
index 96860136599d7064eaf7788a388f6fc6a0639131..3924e1e31f7824c4618727dfd4d0a9e25426c27b 100644 (file)
@@ -13,7 +13,8 @@ _cargo()
        local opt_help='-h --help'
        local opt_verbose='-v --verbose'
        local opt_quiet='-q --quiet'
-       local opt_common="$opt_help $opt_verbose $opt_quiet"
+       local opt_color='--color'
+       local opt_common="$opt_help $opt_verbose $opt_quiet $opt_color"
        local opt_pkg='-p --package'
        local opt_feat='--features --no-default-features'
        local opt_mani='--manifest-path'
index 630a74d09706b8e33fb024e2e09690084a77b115..d3ee5f591b239a760dc8d0c77f3ed518f9e078a2 100644 (file)
@@ -5,7 +5,7 @@ use term::{Terminal, TerminfoTerminal, color};
 use hamcrest::{assert_that};
 
 use cargo::core::shell::{Shell, ShellConfig};
-use cargo::core::shell::Verbosity::{Verbose, Quiet};
+use cargo::core::shell::ColorConfig::{Auto,Always, Never};
 
 use support::{Tap, shell_writes};
 
@@ -22,7 +22,7 @@ impl Write for Sink {
 }
 
 test!(non_tty {
-    let config = ShellConfig { color: true, verbosity: Verbose, tty: false };
+    let config = ShellConfig { color_config: Auto, tty: false };
     let a = Arc::new(Mutex::new(Vec::new()));
 
     Shell::create(Box::new(Sink(a.clone())), config).tap(|shell| {
@@ -34,7 +34,10 @@ test!(non_tty {
 });
 
 test!(color_explicitly_disabled {
-    let config = ShellConfig { color: false, verbosity: Verbose, tty: true };
+    let term = TerminfoTerminal::new(Vec::new());
+    if term.is_none() { return }
+
+    let config = ShellConfig { color_config: Never, tty: true };
     let a = Arc::new(Mutex::new(Vec::new()));
 
     Shell::create(Box::new(Sink(a.clone())), config).tap(|shell| {
@@ -48,7 +51,7 @@ test!(colored_shell {
     let term = TerminfoTerminal::new(Vec::new());
     if term.is_none() { return }
 
-    let config = ShellConfig { color: true, verbosity: Verbose, tty: true };
+    let config = ShellConfig { color_config: Auto, tty: true };
     let a = Arc::new(Mutex::new(Vec::new()));
 
     Shell::create(Box::new(Sink(a.clone())), config).tap(|shell| {
@@ -60,17 +63,20 @@ test!(colored_shell {
                                             color::RED).unwrap()));
 });
 
-test!(quiet_shell {
-    let config = ShellConfig { color: true, verbosity: Quiet, tty: true };
+test!(color_explicitly_enabled {
+    let term = TerminfoTerminal::new(Vec::new());
+    if term.is_none() { return }
+
+    let config = ShellConfig { color_config: Always, tty: false };
     let a = Arc::new(Mutex::new(Vec::new()));
 
     Shell::create(Box::new(Sink(a.clone())), config).tap(|shell| {
-        shell.say("Should be suppressed", color::BLACK).unwrap();
+        shell.say("Hey Alex", color::RED).unwrap();
     });
-
     let buf = a.lock().unwrap().clone();
     assert_that(&buf[..],
-                shell_writes(""));
+                shell_writes(colored_output("Hey Alex\n",
+                                            color::RED).unwrap()));
 });
 
 fn colored_output(string: &str, color: color::Color) -> io::Result<String> {